package com.lrkj.back.service.impl;

import java.util.List;
import java.util.Map;

import com.lrkj.back.mapper.TbEmployeeMapper;
import com.lrkj.back.service.TbEmployeeService;
import com.lrkj.back.entity.TbEmployee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.cbons.mamisay.parent.db.api.DBInterface;
import cn.com.cbons.mamisay.parent.exception.DBException;
import cn.com.cbons.mamisay.parent.service.base.ParentServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Transactional
@Service("employeeService")
public class TbEmployeeServiceImpl extends ParentServiceImpl<TbEmployee> implements TbEmployeeService {
    @Autowired
    private TbEmployeeMapper tbEmployeeMapper;

    @Override
    protected DBInterface<TbEmployee> getDao() throws DBException {
        return tbEmployeeMapper;
    }

    @Override
    public TbEmployee findEmployeeByEmployeeLoginname(String employeeLoginname) throws DBException {
        return tbEmployeeMapper.findEmployeeByEmployeeLoginname(employeeLoginname);
    }

    @Override
    public PageInfo<TbEmployee> queryTbEmployeeList(Map<String, Object> map) throws DBException {
        PageHelper.startPage(Integer.valueOf(map.get("pageNo").toString()),
                Integer.valueOf(map.get("pageSize").toString()));
        List<TbEmployee> tbList = tbEmployeeMapper.queryEmpList(map);
        PageInfo<TbEmployee> page = new PageInfo<TbEmployee>(tbList);
        return page;
    }

    @Override
    public List<TbEmployee> queryEmployeeList(Map<String, Object> map) throws DBException {
        List<TbEmployee> tbList = tbEmployeeMapper.queryEmpList(map);
        return tbList;
    }

    // 修改密码
    @Override
    public int updateEmpPassword(TbEmployee emp) throws DBException {
        int i = 0;
        tbEmployeeMapper.mimaUpdate(emp);
        i = 1;
        return i;
    }

    @Override
    public TbEmployee queryMima(TbEmployee emp) throws DBException {
        TbEmployee st = tbEmployeeMapper.queryMima(emp);
        return st;
    }

    @Override
    public TbEmployee selectByEmployeeNo(String employeeNo) throws DBException {
        return tbEmployeeMapper.selectByEmployeeNo(employeeNo);
    }

    @Override
    public List<TbEmployee> findEmployee(Map<String, Object> map) throws DBException {
        return tbEmployeeMapper.findEmployee(map);
    }

}
